// pages/Home/schoolRow/schoolRow.js
var businessLogic = require('../../../utils/NetWork/Model/HomebusinessLogic.js')
var common = require('../../../utils/common.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //第四步 新建一个data
    post_title:[],
    num:1

  },
  //详情
  schoolRowde: function (event) {
    //跳转
    // console.log(event.currentTarget.dataset.hi) 
    wx.navigateTo({
      url: "../schoolRowde/schoolRowde?id="+event.currentTarget.dataset.hi
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var orgid = common.getStorageSync("orgid")
    var userid = common.getStorageSync("userid")
    var scrollHeight = scrollHeight;
    wx.getSystemInfo({
      success: function (res) {
        scrollHeight = res.windowHeight
      }
    });
    this.setData({
      orgid: orgid,
      userid: userid,
      scrollHeight: scrollHeight,
    });
    this.rongyuLie();
  },
  bindDownLoad: function () {
    if (this.data.lenpage > this.data.num) {
      var di = this.data.num;
      var di = di + 1;
      this.setData({
        num: di
      });
      this.lunbo();
    } else {
      common.showToast("加载全部", "loading");
    }
    //common.showToast("到底了", "loading");

  },
  rongyuLie : function(){
    common.showLoading("加载中", "loading");
    let params = { "page": this.data.num, "num": 10, "orgid": this.data.orgid, "userid": this.data.userid, "searchField": "title,orgid", "searchValue": "," + this.data.orgid + ""  }
    businessLogic.SchoolHonoraryxue(params, (res) => {
      var bbb = this.data.post_title
      for (var a = 0; a < res.infos.length; a++) {
        bbb.push(res.infos[a]);
      }
      this.setData({
        post_title: bbb,
        lenpage: res.page.pages
      });
      common.hideLoading();
    });
  },
  bindKeyInput: function (e) {
    this.setData({
      title: e.detail.value
    })
  },
  search2: function (event) {
    common.showLoading("加载中", "loading");
    let params = { "page": 1, "num": 1000, "orgid": this.data.orgid, "userid": this.data.userid, "searchField": "title,orgid", "searchValue": "" + this.data.title + "," + this.data.orgid + "" }
    businessLogic.SchoolHonoraryxue(params, (res) => {
      var res = res.infos
      this.setData({
        post_title: res
      });
      common.hideLoading();
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})